<?php
class IndexAction extends AgriculturalproductsCommonAction {

	public function verify(){
		$type =	isset($_GET['type'])?$_GET['type']:'gif';
		import("@.ORG.Image");
		Image::buildImageVerify(4,1,$type);
	}
	
	
	// 网站首页
	public function index() {
		//查询推荐产品		
		$queryString_recommend = "select * from product where recommend = 1 and status = 1 order by statusdate desc limit 0,30";
		
		$this->assign("myList",$this->CommonSimplequery(1,$queryString_recommend ,'' ,'' ,0,""));
		
		//查询最新产品
		$queryString_last = "select * from product where status = 1 order by createdate desc limit 0,30"; 
		$this->assign("newList",$this->CommonSimplequery(1,$queryString_last ,'' ,'' ,0,""));
		
		//查询热门产品
		$queryString_hot = "select * from product where status = 1 order by clicktimes desc limit 0,30"; 
		$this->assign("hotList",$this->CommonSimplequery(1,$queryString_hot ,'' ,'' ,0,""));
		
		//查询右边的荣誉证书
		$queryString_hot = " select * from website where code = 'ryzs' order by statusdate desc limit 10"; 
		$this->assign("honorList",$this->CommonSimplequery(1,$queryString_hot ,'' ,'' ,0,""));
		
		//查询右边的新闻中心
		
		$this->rightNewsCommonQuery();
		
		//查询产品类型及所属一、二级分类		
		$queryString_type = "select a.id as id , b.`name` as name ,b.id  as  type_id from product_catalog a , product_type b where a.type_id = b.id group by a.type_id order by a.statusdate desc"; 
		$typeList = $this->CommonSimplequery(1,$queryString_type ,'' ,'' ,0,"") ;
		
		foreach($typeList as $n=> $val_one){		
	      	$typeList[$n]['one']= $this->CommonSimplequery(1,"select * from product_catalog where parentid = 0 and type_id = " . $val_one['type_id'] . " and status =1" ,'' ,'' ,0,"") ;
	      	foreach($typeList[$n]['one'] as $j=> $val_two){   
	      		$typeList[$n]['one'][$j]['two']= $this->CommonSimplequery(1,"select * from product_catalog where parentid = " . $val_two['id'] .  " and status =1 ",'' ,'' ,0,"") ;
	      	}
	    }
	    
		//查询购物车数量
	   	//$this->getShoppingCount();
	    
		$this->assign('typeList',$typeList);
	    
		$this->display();
	}

	
	public function select(){
	    $Dao = M("User");
	    // 计算总数
	    $count = $Dao->count();
	    // 导入分页类
	    import("ORG.Util.Page");
	    // 实例化分页类
	    $p = new Page($count, 10);
	    // 分页显示输出
	    $page = $p->show();
	
	    // 当前页数据查询
	    $list = $Dao->order('uid ASC')->limit($p->firstRow.','.$p->listRows)->select();
	
	    // 赋值赋值
	    $this->assign('page', $page);
	    $this->assign('list', $list);
	
	    $this->display();
	}	
	
}
?>